﻿using System;
using System.Collections.Generic;
using System.Text;
using Abp.Dependency;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using NPOI.Util;

namespace Yozeev.BusinessLogic.DeviceManagement.DomainService
{
    public class DeviceCache: IDeviceCache, ISingletonDependency
    {
        private Dictionary<string, long> _devicesDic;

        public DeviceCache()
        {
            this._devicesDic = new Dictionary<string, long>();
        }

        public void Put(string key, long value)
        {
            _devicesDic[key] = value;
        }

        public Dictionary<string, long> GetMetaData()
        {
            return this._devicesDic;
        }

        public Dictionary<string, long> GetDictionary()
        {
            Dictionary<string, long> data = new Dictionary<string, long>();
            foreach (KeyValuePair<string, long> item in _devicesDic)
            {
                data[item.Key] = item.Value;
            }

            return data;
        }

        public void Remove(string key)
        {
            _devicesDic.Remove(key);
        }

        public void Remove(List<string> keys)
        {
            foreach (var key in keys)
            {
                _devicesDic.Remove(key);
            }
        }

        public void Clear()
        {
            this._devicesDic = new Dictionary<string, long>();
        }
    }
}
